function add(){
    let ok1 =$("checkNameDiv").innerHTML;
    let ok2 =$("checkPwdDiv").innerHTML;
   if (ok1=="用户名可用"&&ok2=="输入正确"){
       adduser();
       location.href="/login.html";
   }
}
function checkName(){
    axios.get("/user/findByName").then(resp=>{
        if ($("userName").value!=null&&$("userName").value!=""){
            if (resp.data=="ok"){
                $("checkNameDiv").innerHTML="用户名可用";
            }else {
                $("checkNameDiv").innerHTML="用户名已存在";
            }
        }else {
            $("checkNameDiv").innerHTML="请输入用户名";
        }

    })
}
function adduser(){
    axios.get("/user/add",{
        params:{
            userName:$("userName").value,
            password:$("password2").value,
            email:$("email").value,
            imgPath:getRadioValue("img")
        }
    }).then(resp=>{
        return "ok";
    })
}
function getRadioValue(args) {
    var element = document.getElementsByName(args);
    // 通过name属性获取到获取对象
    for (var i = 0; i < element.length; i++) {
        // 判断该单选框是否处于选中状态
        if (element[i].checked) {
            return element[i].value;
        }
    }
}

function checkPwd(){
    let p1 = $("password1").value;
    let p2 = $("password2").value;
    if (p1===p2){
        $("checkPwdDiv").innerHTML="输入正确";
        return "ok";
    }
    $("checkPwdDiv").innerHTML="两次输入不一致";
    return "no";
}